<style media="screen">
    .weui-dialog {
        max-width: 400px;
    }

    .weui-dialog__bd {
        max-height: 75vh;
        overflow: scroll;
    }

    #id-type-qusetion {
        cursor: pointer;
    }

    .fixed-block {
        background: #fff;
        max-width: 640px;
    }
    .form-top {
        padding-bottom: 15px;
    }
    .form-top h4 {
        font-size: 20px;
        margin-bottom: 5px;
    }
    .notice {
        border: 1px solid #0036AD;
        margin-bottom: 20px;
    }
    .step-hud {
        padding: 10px 0;
    }
    .step-hud .progress {
        width: 85%;
        margin: 0 auto;
    }
    .form-block {
        padding-bottom: 15px;
    }
    .form-block .form-title{
        border-left: 4px solid #3498DB;
        padding-left: 5px;
        margin: 10px 0px 5px 0;
        line-height: 23px;
        font-size: 19px;
    }
    .form-block .form-sub-title {
        margin-bottom: 5px;
        font-size: 14px;
    }
    .form-block .form-sub-title span {
        line-height: 23px;
    }
    .date-birthday .form-control, #home-address1, #school3 {
        border-color: #bdc3c7;
        color: #34495e;
        opacity: 1;
    }
    .form-group {
        margin-bottom: 10px;
    }

    .select.form-control, .select.select2-search input[type=text] {
        border: 2px solid #bdc3c7;
    }

    .form-group select {
        border: 2px solid #bdc3c7;
        height: 35px!important;
        min-width: unset;
    }
    .form-group .input-group-addon {
        padding: 5px;
        background: none;
        color: #666;
    }
    .border-red {
        border-color: red!important;
        background-color: #ffcdcd!important;
    }
    .text-danger {
        color: #e74c3c!important;
    }
    .weui-dialog__bd {
        overflow: auto;
    }
</style>

<div>

    <div class="notice row fixed-block hide">
        <div class="col-xs-12"><div class="text-center"><small>请确认您的信息正确无误并参加活动。</small></div></div>
    </div>

    <div class="form-top row fixed-block">
        <div class="col-xs-12"><h4 class="text-center"><span id="ac_name"></span>报名登记表</h4></div>
        <div class="col-xs-12"><div class="text-center"><small class="text-danger">(注：红色字体部分为必填项目)</small></div></div>
    </div>
    <hr class="fixed-block">

    <div class="step-hud fixed-block hide">
        <div class="step-info text-center">
            第1步（共4步）
        </div>
        <div class="progress mbn">
            <div class="progress-bar progress-bar-info" style="width: 25%;"></div>
        </div>
    </div>

    <div class="step step1 form-block row fixed-block hide">
        <input id="volunteer" type="hidden" value="<?php echo $_REQUEST['volunteer']; ?>">
        <div class="col-xs-12"><h6 class="form-title">个人信息</h6></div>

        <div class="col-xs-12 col-sm-4">
            <p class="text-danger form-sub-title">姓名<span class="fui-alert-circle hide"></span></p>
            <div class="form-group">
                <input id="user-name" type="text" value="" placeholder="" class="form-control input-sm">
            </div>
        </div>

        <div class="col-xs-12 col-sm-4">
            <p class="text-danger form-sub-title">性别</p>
            <div class="form-group">
                <select id="user-sex" class="form-control select select-default select-block">
                <option value="1">男</option>
                <option value="2">女</option>
                </select>
            </div>
        </div>

        <div class="col-xs-12 col-sm-4">
            <p class="text-danger form-sub-title">出生日期</p>
            <div class="form-group">
                <div class="date-birthday input-group date" data-date="" data-date-format="dd MM yyyy" data-link-field="user-birthday" data-link-format="yyyy-mm-dd">
                    <input class="form-control input-sm" size="16" type="text" value="" readonly>
                    <span class="input-group-addon input-sm"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
                <input type="hidden" id="user-birthday" value="" />
            </div>
        </div>

        <!-- <div class="col-xs-12 col-sm-3">
            <p class="text-danger form-sub-title">健康状况</p>
            <div class="form-group">
                <input id="user-health" type="text" value="" placeholder="" class="form-control input-sm">
            </div>
        </div> -->

        <div class="col-xs-12 col-sm-6">
            <p class="text-danger form-sub-title">证件类型 <span id="id-type-qusetion" class="fui-question-circle"></span></p>
            <div class="form-group">
                <select id="id-type" class="form-control select select-default select-block">
                <option value="">请选择证件类型</option>
                <option value="1">居民身份证</option>
                <option value="2">香港居民身份证</option>
                <option value="3">澳门居民身份证</option>
                <option value="4">护照</option>
                </select>
            </div>
        </div>

        <div class="col-xs-12 col-sm-6">
            <p class="text-danger form-sub-title">证件号码</p>
            <div class="form-group">
                <input id="user-id" type="text" value="" placeholder="" class="form-control input-sm">
            </div>
        </div>

        <div class="col-xs-12 col-sm-6">
            <p class="form-sub-title">户籍所在地（以户口薄为准）</p>
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <select id="hometown-in-foshan" class="form-control select select-default select-block">
                        <option value="1">佛山市内</option>
                        <option value="2">佛山市外</option>
                        </select>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <select id="hometown1" class="form-control select select-default select-block">
                            <option value="">请选择镇街</option>
                        </select>
                    </div>
                    <div class="form-group" style="display: none;">
                        <input id="hometown2" type="text" value="" placeholder="请输入详细住址" class="form-control input-sm">
                    </div>
                </div>
            </div>
        </div>

        <div class="col-xs-12 col-sm-6">
            <p class="form-sub-title">现居住地址(具体到门牌号)</p>
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <input id="home-address1" type="text" value="广东省 佛山市 顺德区" placeholder="请选择所在地区" class="form-control input-sm">
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <input id="home-address2" type="text" value="" placeholder="请输入详细地址" class="form-control input-sm">
                    </div>
                </div>
            </div>
        </div>

    </div>
    <hr class="step step1 fixed-block hide">

    <div class="step step2 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">报名人学校信息</h6></div>
        <div class="col-xs-12">
            <p class="text-danger form-sub-title">毕业学校</p>
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <select id="school1" class="form-control select select-default select-block">
                        <option value="1">顺德区内</option>
                        <option value="2">顺德区外</option>
                        </select>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <div>
                            <select id="school2" class="form-control select select-default select-block">
                                <option value="">请选择镇街</option>
                            </select>
                        </div>
                        <!-- 地区选择器picker -->
                        <div style="display: none;">
                            <input id="school3" type="text" value="广东省 佛山市 顺德区" placeholder="请选择所在地区" class="form-control input-sm">
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <div>
                            <select id="school5" class="form-control select select-default select-block">
                                <option value="">请选择学校</option>
                            </select>
                        </div>
                        <div style="display: none;">
                            <input id="school4" type="text" value="" placeholder="请输入学校全名" class="form-control input-sm">
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon input-sm">六年</span>
                                <input id="school6" type="tel" class="form-control input-sm" placeholder="" />
                                <span class="input-group-addon input-sm">班</span>
                            </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <p class="form-sub-title">全国学籍号(一般为G+身份证号。)</p>
            <div class="form-group">
                <input id="school7" type="text" value="" placeholder="" class="form-control input-sm">
            </div>
        </div>
    </div>
    <hr class="step step2 fixed-block hide">

    <div class="step step3 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">报名人家庭信息</h6></div>
        <div class="col-xs-12">
            <p class="form-sub-title">监护人</p>
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 姓 &nbsp; 名 &nbsp; </span>
                            <input id="father-name" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm">手机号码</span>
                            <input id="father-tel" type="tel" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm">工作单位</span>
                            <input id="father-address" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 职 &nbsp; 务 &nbsp; </span>
                            <input id="father-job" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <p class="form-sub-title">监护人</p>
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 姓 &nbsp; 名 &nbsp; </span>
                            <input id="mother-name" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm">手机号码</span>
                            <input id="mother-tel" type="tel" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm">工作单位</span>
                            <input id="mother-address" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 职 &nbsp; 务 &nbsp; </span>
                            <input id="mother-job" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <p class="form-sub-title">有兄弟姐妹在我校就读请填班级姓名(非必填)</p>
            <div class="form-group">
                <input id="sister" type="text" value="" placeholder="" class="form-control input-sm">
            </div>
        </div>
    </div>
    <hr class="step step3 fixed-block hide">


    <div class="score step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">学生成绩</h6></div>
        <!-- <div class="col-xs-12">
            <p class="form-sub-title">五年级上学期成绩</p>
            <div class="row">
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 语 &nbsp; 文 &nbsp; </span>
                            <input id="five1-yuwen" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 数 &nbsp; 学 &nbsp; </span>
                            <input id="five1-math" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 英 &nbsp; 语 &nbsp; </span>
                            <input id="five1-english" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm">总分排名</span>
                            <input id="five1-rank" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
            </div>
        </div> -->
        <div class="col-xs-12">
            <p class="form-sub-title">五年级下学期成绩</p>
            <div class="row">
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 语 &nbsp; 文 &nbsp; </span>
                            <input id="five2-yuwen" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 数 &nbsp; 学 &nbsp; </span>
                            <input id="five2-math" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="text-danger input-group-addon input-sm"> &nbsp; 英 &nbsp; 语 &nbsp; </span>
                            <input id="five2-english" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm">总分排名</span>
                            <input id="five2-rank" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <p class="form-sub-title">六年级上学期成绩</p>
            <div class="row">
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 语 &nbsp; 文 &nbsp; </span>
                            <input id="six1-yuwen" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 数 &nbsp; 学 &nbsp; </span>
                            <input id="six1-math" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm"> &nbsp; 英 &nbsp; 语 &nbsp; </span>
                            <input id="six1-english" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon input-sm">总分排名</span>
                            <input id="six1-rank" type="text" class="form-control input-sm" placeholder="" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <hr class="score step step4 fixed-block hide">

    <div class="step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">您对学校的办学理念</h6></div>
        <div class="col-xs-12">
            <div class="form-group">
                <select id="school-idea" class="form-control select select-default select-block">
                <option value="1">非常认同</option>
                <option value="2">认同</option>
                <option value="3">基本认同</option>
                <option value="4">不认同</option>
                </select>
            </div>
        </div>
    </div>
    <hr class="step step4 fixed-block hide">
    <!--
    <div class="step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">报读志愿</h6></div>
        <div class="col-xs-12 col-sm-6">
            <p class="text-danger form-sub-title">第一志愿</p>
            <div class="form-group">
                <select id="choice1" class="form-control select select-default select-block">
                    <option value="">选择第一志愿</option>
                    <option value="1">国内部</option>
                    <option value="2">国外部</option>
                </select>
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <p class="form-sub-title">第二志愿</p>
            <div class="form-group">
                <select id="choice2" class="form-control select select-default select-block">
                    <option value="">选择第二志愿</option>
                    <option value="1">国内部</option>
                    <option value="2">国外部</option>
                </select>
            </div>
        </div>
    </div>
    <hr class="step step4 fixed-block hide"> -->


    <div class="award step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">近3年所获荣誉（注意：仅填市级以上荣誉）</h6></div>
        <div class="col-xs-12">
            <p class="form-sub-title">学科类</p>
            <textarea id="award-subject" class="form-control" rows="3"></textarea>
            <br>
            <p class="form-sub-title">才艺类</p>
            <textarea id="award-talent" class="form-control" rows="3"></textarea>
            <br>
            <p class="form-sub-title">其他</p>
            <textarea id="award-other" class="form-control" rows="3"></textarea>
        </div>
    </div>
    <hr class="award step step4 fixed-block hide">


    <div class="step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">学生自述（非必选，最多200字）</h6></div>
        <div class="col-xs-12">
            <textarea id="introduce" class="form-control" rows="3" maxlength="200"></textarea>
        </div>
    </div>
    <hr class="step step4 fixed-block hide">


	<!-- <div class="ac-time step step4 form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">参加时间</h6></div>
        <div class="col-xs-12">
            <div class="form-group">
                <select id="ac-time" class="form-control select select-default select-block">
                <option value>请选择参加时间</option>
                </select>
            </div>
        </div>
    </div> -->
    <hr class="ac-time step step4 fixed-block hide">

    <div class="qrcode form-block row fixed-block hide">
        <div class="col-xs-12"><h6 class="form-title">家长微信扫码绑定账号</h6></div>
        <div class="col-xs-12"><p class="form-sub-title">绑定后可在【广东顺德德胜学校】微信公众号免登录查询面谈成绩</p></div>
        <div class="col-xs-6">
            <div class="content text-right">

            </div>

        </div>
		<div class="col-xs-6  text-left">
            <div class="">
				<img id="wx_headimage" src='' style="border-radius:3px;"/>
				<p id="wx_nickname">请使用微信扫描二维码</p>
            </div>
        </div>
    </div>
    <hr class="qrcode fixed-block hide">

    <div class="form-block row fixed-block text-center">

          <small>
              <label class="checkbox" for="allow-submit" style="display: inline-block">
                <input type="checkbox" value="" id="allow-submit" data-toggle="checkbox">
                  本人保证已如实填写报名信息，如有虚假或造假情况，自愿承担所有后果。
              </label>
          </small>

    </div>

    <div class="form-block row fixed-block" style="padding-bottom: 100px;">
        <div class="col-xs-12 text-center">
            <button id="prev-step" class="btn btn-sm btn-info hide">
              上一步
            </button>
            <button id="next-step" class="btn btn-sm btn-info hide">
              下一步
            </button>
            <button id="submit" class="btn btn-sm btn-info hide">
              提交
            </button>
            <div id="submit-loading" class="weui-loadmore hide">
                <i class="weui-loading"></i>
                <span class="weui-loadmore__tips">正在提交</span>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    $(function() {
        $(':checkbox').radiocheck().on('change.radiocheck', function(e) {
            if (e.currentTarget.checked == true) {
                $(this).attr('checked', 'checked');
            } else {
                $(this).removeAttr('checked');
            }
        });
        $('#allow-submit').radiocheck('check');
		$.modal({
			title: "提示",
			text: "数据正在加载",
			buttons: []
		});

        var pass = true;
        var checkIdPass = true;
        var studentId = null;
        // 是否正式报名
        var isZhaosheng = 1;

        // 学校列表
        var schoolList = [];

        // 字段对应表单id
        var mainInfo = {
            'name': '#user-name',
            'sex': '#user-sex',
            'birth_date': '#user-birthday',
            // 'healthy': '#user-health',
            'identity_type': '#id-type',
            'identity': '#user-id',
            // 籍贯是否在佛山
            'is_in_foshan': '#hometown-in-foshan',
            // 籍贯在佛山
            'street': '#hometown1',
            // 籍贯不在佛山
            'street_desc': '#hometown2',
            // 现居地所在省市区
            'address_desc': '#home-address1',
            // 现居地详细地址
            'address': '#home-address2',
            // 毕业学校是否在顺德内
            'graduate_province': '#school1',
            // 毕业学校在顺德内 镇
            'graduate_street': '#school2',
            // 毕业学校不顺德内 地区
            'graduate_desc': '#school3',
            // 毕业学校在顺德内 学校名
            'graduate_school': '#school5',
            // 毕业学校不顺德内 学校名
            'graduate_school_desc': '#school4',
            // 班级
            'graduate_class': '#school6',
            // 学籍号
            'register_num': '#school7',

            'father': '#father-name',
            'father_tell': '#father-tel',
            'father_address': '#father-address',
            'father_job': '#father-job',

            'mother': '#mother-name',
            'mother_tell': '#mother-tel',
            'mother_address': '#mother-address',
            'mother_job': '#mother-job',

            // 有兄弟姐妹在我校就读
            'sister': '#sister',

            'five1_yuwen': '#five1-yuwen',
            'five1_math': '#five1-math',
            'five1_english': '#five1-english',
            'five1_rank': '#five1-rank',

            'five2_yuwen': '#five2-yuwen',
            'five2_math': '#five2-math',
            'five2_english': '#five2-english',
            'five2_rank': '#five2-rank',

            'six1_yuwen': '#six1-yuwen',
            'six1_math': '#six1-math',
            'six1_english': '#six1-english',
            'six1_rank': '#six1-rank',

            'award_subject': '#award-subject',
            'award_talent': '#award-talent',
            'award_other': '#award-other',
            'school_idea': '#school-idea',

            // 'first_choice': $('#choice1').val(),
            // 'second_choice': $('#choice2').val(),

            'student_desc': '#introduce',

            // 国际部或者国内部
            'volunteer': "#volunteer",
        };
        // 防止回填的值比这个列表加载得要快
        var selectValue = {
            street: '',
            graduate_street: '',
            graduate_school: ''
        }


        // 选择非中国身份证时候弹出填写例子
        function showIdCase(flag) {
            if (flag) {
                $('#id-type').on('change',function() {
                    var isShow = true;
                    var imgSrc = '';
                    switch ($(this).val()) {
                        case '2':
                            console.log('香港');
                            imgSrc = '/Public/statics/desheng/img/hk.jpg';
                            break;
                        case '3':
                            console.log('澳门');
                            imgSrc = '/Public/statics/desheng/img/am.jpg';
                            break;
                        case '4':
                            console.log('护照');
                            imgSrc = '/Public/statics/desheng/img/hz.jpg';
                            break;
                        default:
                            isShow = false;
                            break;
                    }

                    if (isShow) {
                        $.modal({
                          title: "证件示例",
                          text: '<img style="width: 100%;" src="' + imgSrc + '">',
                          buttons: [
                            { text: "确认", className: "", onClick: function() {} },
                          ]
                        });
                    }
                });
            } else {
                $.modal({
                  title: "证件示例",
                  text: '\
                      <p>香港身份证：</p>\
                      <img style="width: 100%;" src="/Public/statics/desheng/img/hk.jpg">\
                      <br />\
                      <p>澳门身份证：</p>\
                      <img style="width: 100%;" src="/Public/statics/desheng/img/am.jpg">\
                      <br />\
                      <p>护照：</p>\
                      <img style="width: 100%;" src="/Public/statics/desheng/img/hz.jpg">\
                      <br />\
                  ',
                  buttons: [
                    { text: "确认", className: "", onClick: function() {} },
                  ]
                });

            }

        }

        // 身份证类型 问题按钮
        $('#id-type-qusetion').on('click', function () {
            showIdCase(false);
        });

        // 检查身份证是否符合生日日期
        function checkIdBirthday() {
            // 非居民身份证不检查
            if ($('#id-type').val() != 1) {
                return true;
            }

            var birthday = $('#user-birthday').val().replaceAll('-', '');
            var idBirthday = $('#user-id').val().substr(6,8);
            if (idBirthday == birthday || birthday == '') {
                $('#user-id').removeAttr('data-check').removeClass('border-red');
                return true;
            } else {
                $('#user-id').attr('data-check', 'no').addClass('border-red');
                $.alert('身份证与出生日期不符');
                pass = false;
                return false;
            }
        }

        // 检测身份证够不够18位
        function checkIdLength() {
            // 非居民身份证不检查
            if ($('#id-type').val() != 1) {
                return true;
            }
            var obj = '#user-id';
            if ($(obj).val().length != 18 && $('#user-id').val() != '') {
                $(obj).attr('data-check', 'no').addClass('border-red');
                pass = false;
                $.alert('请正确填写18位身份证');
                return false;
            } else {
                $(obj).removeAttr('data-check').removeClass('border-red');
                return true;
            }
        }

        // 身份证查重
        function checkId() {
            if ($('#user-id').val() == '') {
                $('#user-id').removeAttr('data-check').removeClass('border-red');
                return;
            }
            if (checkIdLength() == false) {
                return;
            }
            // if (checkIdBirthday() == false) {
            //     return;
            // }
            // if ($('#id-type').val() == 1 && $('#user-id').val() != '' && $('#user-id').val().length != 18) {
            //     return;
            // }
            $.post(parameter.getIdentityExist, {student_id: studentId, identity: $('#user-id').val()}, function(data) {
                if (data == '"0"') {
                    checkIdPass = false;
                    checkIdBirthday();
                    $('#user-id').attr('data-check', 'no').addClass('border-red');
                    $.alert('该身份证已经报名，请勿重复报名。');
                } else {
                    checkIdPass = true;
                    $('#user-id').removeAttr('data-check').removeClass('border-red');
                    checkIdBirthday();
                }
            });
        }

        // 姓名小于2个字提示
        function checkNameLength(obj) {
            if ($(obj).val().length >= 2 || $(obj).val().length == 0) {
                $(obj).removeAttr('data-check').removeAttr('data-check').removeClass('border-red');
            } else {
                $(obj).attr('data-check', 'no').addClass('border-red');
                $.alert('请输入完整姓名信息');
            }
        }

        // 验证手机11位
        function checkPhoneLength(obj) {
            if ($(obj).val().length == 11 || $(obj).val().length == 0) {
                $(obj).removeAttr('data-check').removeAttr('data-check').removeClass('border-red');
            } else {
                $(obj).attr('data-check', 'no').addClass('border-red');
                $.alert('请输入完整11位手机号码');
            }
        }

        // 生日选择器
        $('.date-birthday').datetimepicker({
            language:  'zh-CN',
            format: 'yyyy-mm-dd',
            weekStart: 1,
            todayBtn:  0,
    		autoclose: 1,
    		todayHighlight: 1,
    		startView: 4,
    		minView: 2,
    		forceParse: 0
        });

        // 户籍选择器
        function hometownPicker() {
            $("#home-address1").cityPicker({
                title: "请选择详细地址"
            });
        }
        // hometownPicker();

        // 学校所在地址选择器
        function schoolAddressPicker() {
            $("#school3").cityPicker({
                title: "请选择所在地址"
            });
        }
        // schoolAddressPicker();

        // 户籍是否在佛山切换
        function hometownInFoshanSwitch() {
            switch ($('#hometown-in-foshan').val()) {
                case '1':
                    $('#hometown1').parent('.form-group').show();
                    $('#hometown2').parent('.form-group').hide();
                    break;
                case '2':
                    $('#hometown1').parent('.form-group').hide();
                    $('#hometown2').parent('.form-group').show();
                    break;
            }
        }
        $('#hometown-in-foshan').on('change', function() {
            hometownInFoshanSwitch();
        });

        // 学校地址是否在顺德区内的切换
        function schoolInShundeSwitch() {
            switch ($('#school1').val()) {
                case '1':
                    $('#school2').parent('div').show();
                    $('#school5').parent('div').show();
                    $('#school3').parent('div').hide();
                    $('#school4').parent('div').hide();
                    break;
                case '2':
                    $('#school2').parent('div').hide();
                    $('#school5').parent('div').hide();
                    $('#school3').parent('div').show();
                    $('#school4').parent('div').show();
                    break;
            }
        }

        // 拿各镇街的学校
        function getStreetSchool(street) {
            var arr = [];
            if (street == '大良') {
                for (var i in schoolList) {
                    if (schoolList[i].name.indexOf(street) != -1 || schoolList[i].name.indexOf('顺德德胜') != -1 || schoolList[i].name.indexOf('顺德一中') != -1 || schoolList[i].name.indexOf('顺德养正') != -1 || schoolList[i].name.indexOf('凤城实验') != -1) {
                        arr.push(schoolList[i]);
                    }
                }
            } else if (street == '容桂') {
                for (var i in schoolList) {
                    if (schoolList[i].name.indexOf(street) != -1 || schoolList[i].name.indexOf('广东实验中学顺德学校附属小学') != -1) {
                        arr.push(schoolList[i]);
                    }
                }
            } else {
                for (var i in schoolList) {
                    if (schoolList[i].name.indexOf(street) != -1) {
                        arr.push(schoolList[i]);
                    }
                }
            }
            return arr;
        }

        function appendSchool(street) {
            var text = '<option value="">请选择学校</option>';
            var arr = street ? getStreetSchool(street) : schoolList;
            // console.log(arr);
            for (var i in arr) {
                text += '<option ' + arr[i].isSelect + ' value="' + arr[i].value + '">' + arr[i].name + '</option>';
            }
            $('#school5').html(text);
        }

        // 顺德区内镇街切换时切换镇街内学校
        function shundeSchoolSwitch() {
            $('#school5').val('');
            var selectStreetValue = $('#school2').val();
            appendSchool($('#school2 option[value=' + selectStreetValue + ']').html().substr(2, 4));
            // console.log($('#school2').val() + $('#school2 option:selected').html());
        }
        $('#school1').on('change', function() {
            schoolInShundeSwitch();
        });

        $('#school2').on('change', function() {
            shundeSchoolSwitch();
            console.log(schoolList);
        });

        // 判断是不是从活动入口进来
		var isActivity = "<?php echo $acid; ?>"||null;
        if (isActivity != null) {
            $('.notice').removeClass('hide');
        }

        // 获取区内学校列表
        $.get(parameter.getSchoolList, function(data) {
            var json = JSON.parse(data);
            var text = '';
            var selectSchoolStreet = '';
            for(var i in json) {
                // 防止回填的值比这个列表加载得要快
                var isSelect = selectValue.graduate_school == json[i].list_item_id ? 'selected' : '';
                // text += '<option ' + isSelect + ' value="' + json[i].list_item_id + '">' + json[i].item_desc + '</option>';
                schoolList.push({
                    'isSelect': isSelect,
                    'value': json[i].list_item_id,
                    'name': json[i].item_desc,
                });
                // 已经选择了学校
                if (isSelect != '') {
                    selectSchoolStreet = json[i].item_desc.substr(0, 2) == '顺德' ? '大良' : json[i].item_desc.substr(0, 2);
                }
            };
            if (selectSchoolStreet == '') {
                appendSchool();
            } else {
                appendSchool(selectSchoolStreet);
            }
            // $('#school5').append(text);
        });


        // 获取区内镇街列表
        $.get(parameter.getStreetList, function(data) {
            var json = JSON.parse(data);
            var text = '';
            for(var i in json) {
                // 防止回填的值比这个列表加载得要快
                var isSelect = selectValue.graduate_street == json[i].list_item_id ? 'selected' : '';
                text += '<option ' + isSelect + ' value="' + json[i].list_item_id + '">' + json[i].item_desc + '</option>';
            };
            $('#school2').append(text);
        });

        // 获取市内户籍镇街列表
        $.get(parameter.getHometownList, function(data) {

            var json = JSON.parse(data);
            var text = '';
            for(var i in json) {
                // 防止回填的值比这个列表加载得要快
                var isSelect = selectValue.street == json[i].list_item_id ? 'selected' : '';
                text += '<option ' + isSelect + ' value="' + json[i].list_item_id + '">' + json[i].item_desc + '</option>';
            };
            $('#hometown1').append(text);
        });

        // 表单回填
		var loadAcid = "<?php echo $_REQUEST['acid']; ?>"||'';

        $.closeModal();
        // $.post(parameter.userInfoGet, {add_phone: getCookie('user'),activity_id:loadAcid}, function(data) {
        //     var json = JSON.parse(data);
        //     studentId = json.student_id;
        //
		// 	var text = '';
        //
		// 	if (json.timesInfo) {
		// 		for (var i in json.timesInfo) {
		// 			text += '<option value="' + json.timesInfo[i].acti_time_id + '">' + json.timesInfo[i].title + '</option>';
		// 		}
        //
		// 		$('#ac-time').append(text).val(json.isBaoInfo.acti_time_id);
        //         if ('<?php echo $_REQUEST['volunteer']; ?>' == 1) {
        //             // 国内部
        //             $('#ac_name').html(json['activInfo']['title']);
        //         } else {
        //             // 国际部
        //             $('#ac_name').html(json['activInfo']['title'].replace('初一', '国际部'));
        //         }
		// 	}
		// 	//console.log(json.activInfo.is_sign_up)
		// 	if(json.activInfo){
		// 		isZhaosheng = json.activInfo.is_zhaosheng;
		// 	}
        //     toggleSignUpForm();
        //
        //     if (json.name && json.name != '') {
        //         for (var i in mainInfo) {
        //             if (i == 'birth_date') {
        //                 // 生日
        //                 var birthday = (new Date(json.birth_date * 1000)).format('yyyy-MM-dd');
        //                 // console.log(birthday);
        //                 $('#user-birthday').val(birthday);
        //                 $('.date-birthday .form-control').val(birthday);
        //                 $('.date-birthday').datetimepicker('update');
        //             } else if (i == 'volunteer') {
        //                 continue;
        //             } else {
        //                 // 防止回填的值比这个列表加载得要快
        //                 if (i == 'street' || i == 'graduate_street' || i == 'graduate_school') {
        //                     selectValue[i] = json[i];
        //                 }
        //                 $(mainInfo[i]).val(json[i]);
        //             }
        //         }
        //         showIdCase(true);
        //         hometownPicker();
        //         schoolAddressPicker();
        //         hometownInFoshanSwitch();
        //         schoolInShundeSwitch();
        //
        //         $('#user-id').on('blur', function() {
        //             checkId();
        //         });
        //         // $('#user-name').on('blur', function() {
        //         //     checkNameLength('#user-name');
        //         // });
        //         // $('#father-name').on('blur', function() {
        //         //     checkNameLength('#father-name');
        //         // });
        //         // $('#mother-name').on('blur', function() {
        //         //     checkNameLength('#mother-name');
        //         // });
        //         $('#father-tel').on('blur', function() {
        //             checkPhoneLength('#father-tel');
        //         });
        //         $('#mother-tel').on('blur', function() {
        //             checkPhoneLength('#mother-tel');
        //         });
		// 		var wx_info = JSON.parse(json['ws_info']);
		// 		$('#wx_headimage').attr('src',wx_info['headimgurl']);
		// 		$('#wx_nickname').html(wx_info['nickname']);
        //
        //         for (var i in schoolList) {
        //             if (schoolList[i].value == json.graduate_school) {
        //                 schoolList[i].isSelect = 'selected';
        //                 break;
        //             }
        //         }
        //         // 学校列表append
        //         $('#school2 option').each(function() {
        //             if (json.graduate_street == $(this).val()) {
        //                 appendSchool($(this).html().substr(2, 2));
        //             }
        //         });
        //
        //         // 锁定表格
        //         console.log(json.is_confirm);
        //         if (json.is_confirm == 1) {
        //             disablForm();
        //         }
        //     } else {
        //         showIdCase(true);
        //         hometownPicker();
        //         schoolAddressPicker();
        //         hometownInFoshanSwitch();
        //         schoolInShundeSwitch();
        //         $('#user-id').on('blur', function() {
        //             checkId();
        //         });
        //         // $('#user-name').on('blur', function() {
        //         //     checkNameLength('#user-name');
        //         // });
        //         // $('#father-name').on('blur', function() {
        //         //     checkNameLength('#father-name');
        //         // });
        //         // $('#mother-name').on('blur', function() {
        //         //     checkNameLength('#mother-name');
        //         // });
        //         $('#father-tel').on('blur', function() {
        //             checkPhoneLength('#father-tel');
        //         });
        //         $('#mother-tel').on('blur', function() {
        //             checkPhoneLength('#mother-tel');
        //         });
        //     }
        //
		// 	$.closeModal();
        // });


        // 禁用disabled表单
        function disablForm() {
            $('.notice').removeClass('hide').find('small').html('报名表已经确认，无法修改信息');
            for (var i in mainInfo) {
                // 不需要禁用的
                if (i == 'five1_yuwen' || i == 'five1_math' || i == 'five1_english' || i == 'five1_rank' || i == 'five2_yuwen' || i == 'five2_math' || i == 'five2_english' || i == 'five2_rank' || i == 'six1_yuwen' || i == 'six1_math' || i == 'six1_english' || i == 'six1_rank' || i == 'award_subject' || i == 'award_talent' || i == 'award_other') {
                    continue;
                }
                // console.log(mainInfo[i]);
                $(mainInfo[i]).attr('disabled', 'disabled').attr('readonly', 'readonly');
            }
            setTimeout(function() {
                $('.date-birthday').datetimepicker('remove');
            }, 300);
        }

        // 验证
        function check(obj, target) {
            if ($(obj).val() == '' || $(obj).val() == null || $(obj).attr('data-check') == 'no') {
                if (target) {
                    $(target).addClass('border-red');
                } else {
                    $(obj).addClass('border-red');
                }
                pass = false;
            } else {
                if (target) {
                    $(target).removeClass('border-red');
                } else {
                    $(obj).removeClass('border-red');
                }
            }
        }

        function check1() {
            // 第一步
            check('#user-name');
            check('#user-sex');
            check('#user-birthday', '.date-birthday .form-control');
            // check('#user-health');
            check('#id-type');
            // check('#user-id');
            // 如果是选择居民身份证
            if ($('#id-type').val() == 1) {
                if (checkIdLength() == false) {
                    return;
                }
                checkIdBirthday();
            }
            if (checkIdPass == false) {
                $('#user-id').attr('data-check', 'no').addClass('border-red');
                // $.alert('该身份证已经报名，请勿重复报名。');
                pass = false;
            }
            // check('#hometown-in-foshan');
            // if ($('#hometown-in-foshan').val() == 1) {
            //     check('#hometown1');
            // } else {
            //     check('#hometown2');
            // }
            // check('#home-address1');
            // check('#home-address2');
        }
        function check2() {
            // 第二部
            check('#school1');
            if ($('#school1').val() == 1) {
                check('#school2');
                check('#school5');
            } else {
                check('#school3');
                check('#school4');
            }
            check('#school6');
            // check('#school7');
        }
        function check3() {
            // 第三部
            check('#father-name');
            check('#father-tel');
            check('#father-address');
            check('#father-job');
            // check('#mother-name');
            // check('#mother-tel');
            // check('#mother-address');
        }
        function check4() {
            // 第四部
            check('#five2-yuwen');
            check('#five2-math');
            check('#five2-english');
            check('#school-idea');
            // check('#choice1');
			// if (isZhaosheng != 1) {
			// 	check('#ac-time');
			// }

        }



        // 提交按钮
        $('#submit').on('click', function() {
            // 没有点击通知
            if ($('#allow-submit').attr('checked') == undefined) {
                $.alert('请确认本人保证已如实填写报名信息， 并勾选');
                return;
            }

            if ($(this).hasClass('disabled')) {
                return;
            }
            pass = true;
            // 信息字段
            var info = {
                'student_id': studentId,
                'add_phone': getCookie('user'),
            }
            for (var i in mainInfo) {
                if (i == 'birth_date') {
                    info[i] = parseInt(Date.parse($('#user-birthday').val()) / 1000).toString();
                } else {
                    info[i] = $(mainInfo[i]).val();
                    if (i == 'volunteer' && $(mainInfo[i]).val() == '') {
                        info[i] = 1;
                    }
                }
            }
            // console.log(info);

            check1();
            check2();
            check3();
            check4();
            if (pass == false) {
                $.alert('请正确填写红框内容');
                return;
            }


            $('#submit').addClass('disabled');
            $('#submit-loading').removeClass('hide');

            $.post(parameter.userInfoSend, info, function(data) {
                $('#submit').removeClass('disabled');
                $('#submit-loading').addClass('hide');
                var json = JSON.parse(data);
                switch (json.status) {
                    case 1:
                        var actId = "<?php echo $acid; ?>"|| null;
                        if (actId == null) {
                            $.toast("提交成功", function() {
                                // window.location.href = './activity';
								 window.location.href = '{:U("StudentApi/activity")}';
                            });
                        } else {
                            // 报名活动
                            $.post(parameter.signActivity, {activity_id: actId, 'student_id': studentId, 'acti_time_id': $('#ac-time').val()}, function(data) {
                                $.toast('提交成功', function() {
                                    // window.location.href = './activity';
                                     window.location.href = '{:U("StudentApi/activity")}';
                                });
                            });
                        }
                        break;
                    case -1:
                        $.toast("请扫码二维码", 'forbidden', function() {
                            console.log("失败");
                        });
                        break;
                    case '-2':
                        $.toast("该身份证已经报名，请勿重复报名。", 'forbidden', function() {
                            console.log("失败");
                        });
                        break;
                    case '-3':
                        $.toast("网络错误，请重新报名招生活动", 'forbidden', function() {
                            // window.location.href = "{:U('StudentApi/activity',array('type'=>''))}";
                            console.log("失败");
                        });
                        break;
                }
            });

        });

        // 手机版 进度模式显示

        // 改变步骤
        function changeStep(stepIndex) {
            $('.step-hud .step-info').html('第' + stepIndex + '步(共4步)');
            $('.step-hud .progress-bar').css('width', stepIndex / 4 * 100 + '%');
            switch (stepIndex) {
                case 1:
                    $('.step, #prev-step, #next-step, #submit').addClass('hide');
                    $('.step' + stepIndex + ', #next-step').removeClass('hide');
                    break;
                case 4:
                    $('.step, #prev-step, #next-step, #submit').addClass('hide');
                    $('.step' + stepIndex + ', #prev-step, #submit').removeClass('hide');
                    break;
                default:
                    $('.step, #prev-step, #next-step, #submit').addClass('hide');
                    $('.step' + stepIndex + ', #prev-step, #next-step').removeClass('hide');
                    break;
            }
        }


        if (isMobile()) {
            var stepIndex = 1;
            $('.step-hud').removeClass('hide');
            changeStep(stepIndex);
            $('#prev-step').on('click', function() {
                stepIndex --;
                changeStep(stepIndex);
            });
            $('#next-step').on('click', function() {
                pass = true;
                switch (stepIndex) {
                    case 1:
                        check1();
                        break;
                    case 2:
                        check2();
                        break;
                    case 3:
                        check3();
                        break;
                    case 4:
                        check4();
                        break;
                }
                if (pass == false) {
                    $.alert('请正确填写红框内容');
                    return;
                }
                stepIndex ++;
                changeStep(stepIndex);
            });
        } else {
            // 二维码
            $('.qrcode').removeClass('hide');
            setQr('.qrcode .content');

            $('.step, #submit').removeClass('hide');
        }

        function toggleSignUpForm() {
            // 是否正式报名
            if (isZhaosheng == 1) {
                $('.score, .award, .ac-time').remove();
            } else {
                if (isMobile() == false) {
                    $('.score, .award, .ac-time').removeClass('hide');

                }
            }
        }

    });
</script>
